package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Shopeeshopinfomonitor;
import com.ruoyi.system.service.IShopeeshopinfomonitorService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * shopee店铺监控Controller
 * 
 * @author ruoyi
 * @date 2020-12-26
 */
@Controller
@RequestMapping("/system/shopeeshopinfomonitor")
public class ShopeeshopinfomonitorController extends BaseController
{
    private String prefix = "system/shopeeshopinfomonitor";

    @Autowired
    private IShopeeshopinfomonitorService shopeeshopinfomonitorService;

    @RequiresPermissions("system:shopeeshopinfomonitor:view")
    @GetMapping()
    public String shopeeshopinfomonitor()
    {
        return prefix + "/shopeeshopinfomonitor";
    }

    /**
     * 查询shopee店铺监控列表
     */
    @RequiresPermissions("system:shopeeshopinfomonitor:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Shopeeshopinfomonitor shopeeshopinfomonitor)
    {
        startPage();
        List<Shopeeshopinfomonitor> list = shopeeshopinfomonitorService.selectShopeeshopinfomonitorList(shopeeshopinfomonitor);
        return getDataTable(list);
    }

    /**
     * 导出shopee店铺监控列表
     */
    @RequiresPermissions("system:shopeeshopinfomonitor:export")
    @Log(title = "shopee店铺监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Shopeeshopinfomonitor shopeeshopinfomonitor)
    {
        List<Shopeeshopinfomonitor> list = shopeeshopinfomonitorService.selectShopeeshopinfomonitorList(shopeeshopinfomonitor);
        ExcelUtil<Shopeeshopinfomonitor> util = new ExcelUtil<Shopeeshopinfomonitor>(Shopeeshopinfomonitor.class);
        return util.exportExcel(list, "shopeeshopinfomonitor");
    }

    /**
     * 新增shopee店铺监控
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存shopee店铺监控
     */
    @RequiresPermissions("system:shopeeshopinfomonitor:add")
    @Log(title = "shopee店铺监控", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Shopeeshopinfomonitor shopeeshopinfomonitor)
    {
        return toAjax(shopeeshopinfomonitorService.insertShopeeshopinfomonitor(shopeeshopinfomonitor));
    }

    /**
     * 修改shopee店铺监控
     */
    @GetMapping("/edit/{shopid}")
    public String edit(@PathVariable("shopid") String shopid, ModelMap mmap)
    {
        Shopeeshopinfomonitor shopeeshopinfomonitor = shopeeshopinfomonitorService.selectShopeeshopinfomonitorById(shopid);
        mmap.put("shopeeshopinfomonitor", shopeeshopinfomonitor);
        return prefix + "/edit";
    }

    /**
     * 修改保存shopee店铺监控
     */
    @RequiresPermissions("system:shopeeshopinfomonitor:edit")
    @Log(title = "shopee店铺监控", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Shopeeshopinfomonitor shopeeshopinfomonitor)
    {
        return toAjax(shopeeshopinfomonitorService.updateShopeeshopinfomonitor(shopeeshopinfomonitor));
    }

    /**
     * 删除shopee店铺监控
     */
    @RequiresPermissions("system:shopeeshopinfomonitor:remove")
    @Log(title = "shopee店铺监控", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(shopeeshopinfomonitorService.deleteShopeeshopinfomonitorByIds(ids));
    }
}
